﻿package blob.mechanisms
{
    import blob.characters.*;
    import org.flixel.*;

    public class Switch extends FlxSprite implements Mechanism
    {
        private var img:Class;
        private var isActivated:Boolean;
        private var mech:Mechanism;

        public function Switch(param1:Number, param2:Number, param3:Mechanism)
        {
            this.img = Switch_img;
            super(param1, param2);
            loadGraphic(this.img, true, true, 16, 25);
            addAnimation("active", [1], 1, false);
            addAnimation("non_active", [0], 1, false);
            this.isActivated = false;
            this.mech = param3;
            return;
        }// end function

        public function activate(param1:Character) : void
        {
            if (!this.isActivated)
            {
                this.isActivated = true;
            }
            else
            {
                this.isActivated = false;
            }
            this.mech.activate(param1);
            return;
        }// end function

        public function toggle() : void
        {
            return;
        }// end function

        override public function update() : void
        {
            if (this.isActivated)
            {
                play("active");
            }
            else
            {
                play("non_active");
            }
            return;
        }// end function

    }
}
